<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
<?php
class Person
{
	function __construct($name, $sex)		//这是一个构造函数
	{
		$this->name=$name;					//所有变量都有$符号, ->是‘的’的意思
		$this->sex=$sex;
	}
	
	function showName()						//方法			
	{
		echo $this->name;					//echo  相当于JS中的alert
	}
	
	function showSex()
	{
		echo $this->sex;
	}
}
//$p1=new Person('blue', '男');
//$p1->showName();

class Worker extends Person					//表示worker是从Person那继承来的
{
	function __construct($name, $sex, $job)
	{
		parent::__construct($name, $sex);		//从父级继承来的东西
		$this->job = $job;
	}
	
	function showJob()
	{
		echo $this->job;
	}
}
$w1 = new Worker('red', '女', 'CEO');
$w1->showName();
?>
</body>
</html>